<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" lang="cn">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>日常经费列表</title>
    <!-- Tell the browser to be responsive to screen width -->
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <!-- Bootstrap 3.3.7 -->
    <!--link导入外部的css，js样式，如果导入的资源和本页面在同一个文件夹下，直接文件名即可-->
    <link rel="stylesheet" th:href="@{/asserts/bower_components/bootstrap/dist/css/bootstrap.min.css}">
    <!-- jQuery 3 -->
    <script th:src="@{/asserts/bower_components/jquery/dist/jquery.min.js}"></script>
    <!-- Bootstrap 3.3.7 -->
    <script th:src="@{/asserts/bower_components/bootstrap/dist/js/bootstrap.min.js}"></script>
    <!-- Font Awesome -->
    <link rel="stylesheet" th:href="@{/asserts/bower_components/font-awesome/css/font-awesome.min.css}">
    <!-- Ionicons -->
    <link rel="stylesheet" th:href="@{/asserts/bower_components/Ionicons/css/ionicons.min.css}">
    <!-- DataTables -->
    <link rel="stylesheet" th:href="@{/asserts/bower_components/datatables.net-bs/css/dataTables.bootstrap.min.css}">
    <!-- Theme style -->
    <link rel="stylesheet" th:href="@{/asserts/dist/css/AdminLTE.min.css}">

    <!--MySources-->
    <script th:src="@{/asserts/Apolar_sh/lib/js/bigautocomplete.js}"></script>
    <link rel="stylesheet" th:href="@{/asserts/Apolar_sh/lib/css/bigautocomplete.css}" type="text/css"/>
    <script th:src="@{/asserts/Apolar_sh/lib/js/fileinput.min.js}"></script>
    <script th:src="@{/asserts/Apolar_sh/lib/js/fileinput_locale_zh.js}"></script>
    <link th:href="@{/asserts/Apolar_sh/lib/css/fileinput.min.css}" media="all" rel="stylesheet" type="text/css"/>
    <!-- Google Font -->
    <link rel="stylesheet"
          href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic">
    <style type="text/css">
        .search {
            margin-top: 40px;
            margin-left: 40px;
            position: relative;
        }

        #myTable td {
            text-align: center;
            line-height: 25px;
        }

        th {
            text-align: center;
        }

        ul li a {
            font-size: 10px;
        }

        #top {
            background-color: rgba(172, 175, 175, 0.78);
            display: none;
            position: fixed;
            right: -3px;
            bottom: 130px;
            z-index: 9999;
        }

        #top a {
            color: rgba(61, 61, 61, 0.91);
            font-size: 45px;
        }

        #home {
            display: block;
            position: absolute;
            right: 10px;
            top: 8px;
            z-index: 9999;
            font-size: 30px;
        }

        #refresh {
            display: block;
            position: absolute;
            right: 46px;
            top: 10px;
            z-index: 9999;
            font-size: 26px;
        }
    </style>

</head>
<body>
<a id="up"></a>
<div id="top">
    <a href="#up" title="回到顶部" class="fa fa-angle-double-up"></a>
</div>
<span>
    <a id="refresh" class="fa fa-refresh"  href="javascript:location.reload()"></a>
    <a id="home" class="fa fa-home" th:href="@{/ds/dsShow}"></a>
</span>
<div class="wrapper" style="width: 100%;">
    <!-- Content Wrapper. Contains page content -->
    <!-- Content Header (Page header) -->
    <!-- Main content -->
    <section class="content-header" style="padding-top: 10px;">
        <h4>
            <i class="fa fa-search"></i> 搜索日常经费
        </h4>
    </section>
    <div class="search" style="margin-top: 0;width: 100%;">
        <div class="row" style="margin-top: 0;width: 100%;">
            <div class="col-xs-8" style="margin-left: 13%;margin-top: 0;width: 100%;">
                <form class="form-inline" id="SearchForm" th:action="@{/ds/dsSearchShow(pageSize=${pageSize})}"
                      method="post">

                    <span class="form-group">
                        <label>住宿人：</label>
                        <input id="dsPeople" th:if="${cdsc}==null" style="width: 160px;" type="text"
                               class="form-control input-sm"
                               name="cdscPeople"
                               placeholder="请输入住宿人（其中一名)">
                        <input id="dsPeople" th:if="${cdsc}!=null" style="width: 160px;" type="text"
                               class="form-control input-sm"
                               name="cdscPeople"
                               placeholder="请输入住宿人（其中一名)" th:value="${cdsc.cdscPeople}">
                    </span>&nbsp;&nbsp;&nbsp;&nbsp;
                    <span class="form-group">
                        <label>员工名：</label>
                        <input id="dsSeller" th:if="${cdsc}==null" style="width: 130px;" type="text"
                               class="form-control input-sm"
                               name="cdscSeller"
                               placeholder="请输入员工姓名">
                        <!--                               onchange="if(/[\d]/g.test(value)){layer.msg('格式不对哦!请输入字母或中文', {icon: 0, time: 1500});value='';}">-->
                        <input id="dsSeller" th:if="${cdsc}!=null" style="width: 130px;" type="text"
                               class="form-control input-sm"
                               name="cdscSeller"
                               placeholder="请输入员工" th:value="${cdsc.cdscSeller}">
                        <!--                               onchange="if(/[\d]/g.test(value)){layer.msg('格式不对哦!请输入字母或中文', {icon: 0, time: 1500});value='';}">-->
                    </span>&nbsp;&nbsp;&nbsp;&nbsp;
                    <span class="form-group">
                        <label>发生日期：</label>
                        <input id="dsDate" th:if="${cdsc}==null" type="date" class="form-control input-sm"
                               name="cdscDate">
                        <input id="dsDate" th:if="${cdsc}!=null" type="date" class="form-control input-sm"
                               name="cdscDate"
                               th:value="${cdsc.cdscDate}">
                    </span>&nbsp;&nbsp;&nbsp;&nbsp;
                    <button id="submitBtn" type="submit" class="btn btn-success btn-sm"><i class="fa fa-search"></i>
                        一键搜索
                    </button>
                </form>
            </div>
            <!-- /.col -->
        </div>
        <!-- /.row -->
    </div>

    <!-- /.content -->
</div>

<div class="wrapper">
    <!-- Content Wrapper. Contains page content -->
    <!-- Content Header (Page header) -->
    <section class="content-header" style="padding-top: 0;padding-bottom: 2px;">
        <h4>
            <i class="fa fa-navicon"></i> 日常经费列表（单位/元）
        </h4>
        <span style="font-size: 15px;">每页显示：</span>
        <select id="pageSize" name="pageSize" style="height:25px;width: 45px;padding-right: 0;"
                th:onchange="pageFun(this)">
            <option th:selected="${pageSize==5}" value="5">5</option>
            <option th:selected="${pageSize==10}" value="10">10</option>
            <option th:selected="${pageSize==20}" value="20">20</option>
        </select>
        <span style="margin: 0 0 0 75%;">
            <a th:if="${info!=null}" class="btn btn-info btn-sm"
               th:href="@{dsAddUI(currentPage=1,pageSize=5)}"><i
                    class="fa fa-plus"></i> 添加经费信息</a>
            <a th:if="${info==null}" class="btn btn-info btn-sm"
               th:href="@{dsAddUI(currentPage=${pageBean.pageNum},pageSize=${pageSize})}"><i
                    class="fa fa-plus"></i> 添加经费信息</a>
        </span>
    </section>


    <!-- Main content -->
    <section class="content" style="padding-top: 0;">
        <div class="row">
            <div class="col-xs-12">
                <div class="box">
                    <div th:if="${info!=null&&cdsc!=null}" class="box-body" style="color: red;font-size: 20px;">
                        [[${info}]]
                    </div>
                    <div th:if="${info!=null&&cdsc==null}" class="box-body" style="color: red;font-size: 20px;">
                        [[${info}]]<br>
                        <a class="btn btn-primary btn-sm" style="padding: 5px 15px;"
                           th:href="@{/ds/exportTemplate}"
                           onclick="layer.msg('正在导出,请稍等...', { icon: 1, time: 1000 });">
                            <i class="fa fa-download"></i> 导出当前页EXCEL模板
                        </a>
                        <a class="btn btn-primary btn-sm" data-toggle="modal" data-target="#mydialog1">
                            <i class="fa fa-upload"></i> 导入EXCEL
                        </a>
                    </div>

                    <!-- Excel Modal -->
                    <div class="modal fade" id="mydialog1"
                         tabindex="-1" role="dialog" data-backdrop='static'
                         aria-labelledby="myModalLabel">
                        <div class="modal-dialog" role="document">
                            <div class="modal-content">
                                <div class="modal-header">
                                    <h4 class="modal-title" style="text-align: center;">
                                        <i class="fa fa-upload"></i>&nbsp;&nbsp;导入EXCEL
                                    </h4>
                                </div>
                                <div class="modal-body">
                                    <form id="uploadForm" enctype="multipart/form-data">
                                        <div class="form-group">
                                            <input id="input-b2" name="file" size="100" type="file" class="file"
                                                   data-show-preview="true"
                                                   data-show-upload="false"
                                                   data-show-cancel="false"
                                                   accept="application/vnd.ms-excel"
                                                   placeholder="请选择一个Excel文件">
                                        </div>
                                        <div class="modal-footer" style="padding-right: 0;padding-bottom:0;">
                                            <button type="button" class="btn btn-default btn-sm"
                                                    data-dismiss="modal">
                                                <i class="fa fa-close"></i> &nbsp;&nbsp;取&nbsp;&nbsp;消&nbsp;&nbsp;
                                            </button>
                                            <button type="button" class="btn btn-success btn-sm"
                                                    th:onclick="uploadExcel()">
                                                <i class="fa fa-upload"></i> &nbsp;&nbsp;上&nbsp;&nbsp;传&nbsp;&nbsp;
                                            </button>
                                        </div>
                                    </form>
                                </div>
                            </div>
                        </div>
                    </div>
                    <!-- Excel Modal -->

                    <div th:if="${info==null}" class="box-body">
                        <table id="myTable" class="table table-bordered table-striped">
                            <thead>
                            <tr>
                                <th>选择</th>
                                <th>发生日期</th>
                                <th>交通打的</th>
                                <th>交通其他</th>
                                <th>交通总计</th>
                                <th>住宿</th>
                                <th>学生招待</th>
                                <th>领导招待</th>
                                <th>劳务报酬</th>
                                <th>其它</th>
                                <th>员工</th>
                                <th>合计</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            <tr th:each="ds:${pageBean.list}">
                                <td>
                                    <input type="checkbox" name="dsIds" th:value="${ds.dsId}" id="checkId"
                                           th:onchange="recordId(this)">
                                </td>
                                <td>[[${#dates.format(ds.dsDate, 'yyyy-MM-dd')}]]</td>
                                <td>[[${ds.dsTrafficTaxi}]]</td>
                                <td>[[${ds.dsTrafficOther}]]</td>
                                <td>[[${ds.dsTrafficTotal}]]</td>
                                <td>[[${ds.dsStayTotalprice}]]</td>
                                <td>[[${ds.dsEntertainStu}]]</td>
                                <td>[[${ds.dsEntertainLeader}]]</td>
                                <td>[[${ds.dsServices}]]</td>
                                <td>[[${ds.dsOther}]]</td>
                                <td>[[${ds.dsSeller}]]</td>
                                <td>[[${ds.dsTotal}]]</td>
                                <td>
                                    <a class="btn btn-info btn-xs" data-toggle="modal"
                                       th:data-target="${'#detilModal'+ds.dsId}">
                                        <i class="fa fa-info"></i> 其它详情
                                    </a>
                                    <a class="btn btn-warning btn-xs" th:onclick="modify([[${ds.dsId}]])">
                                        <i class="fa fa-edit"></i> 修改
                                    </a>
                                    <a th:if="${session.user.authority!=3}" class="btn btn-danger btn-xs"
                                       th:onClick="ds_delete(this,[[${ds.dsId}]])">
                                        <i class="fa fa-trash"></i> 删除
                                    </a>
                                    <!-- 查看详情 Modal -->
                                    <div class="modal fade" th:id="${'detilModal'+ds.dsId}" tabindex="-1" role="dialog"
                                         aria-labelledby="myModalLabel">
                                        <div class="modal-dialog" role="document">
                                            <div class="modal-content">
                                                <div class="modal-header">
                                                    <button type="button" class="close" data-dismiss="modal"
                                                            aria-label="Close">&nbsp;&nbsp;&times;&nbsp;&nbsp;
                                                    </button>
                                                    <h4 class="modal-title" id="myModalLabel"
                                                        style="text-align: center;"><i class="fa fa-info"></i>&nbsp;&nbsp;其它经费详情
                                                    </h4>
                                                </div>
                                                <div class="modal-body">
                                                    <table class="table table-striped table-bordered">
                                                        <tbody>
                                                        <tr>
                                                            <td style="width: 30%;"><strong>住宿人:</strong></td>
                                                            <td>[[${ds.dsStayPeople}]]</td>
                                                        </tr>
                                                        <tr>
                                                            <td style="width: 30%;"><strong>住宿间数:</strong></td>
                                                            <td>[[${ds.dsStayCount}]]</td>
                                                        </tr>
                                                        <tr>
                                                            <td style="width: 30%;"><strong>住宿单价/元:</strong></td>
                                                            <td>[[${ds.dsStayUnitprice}]]</td>
                                                        </tr>
                                                        <tr>
                                                            <td style="width: 30%;"><strong>其它费用说明:</strong></td>
                                                            <td>[[${ds.dsOtherState}]]</td>
                                                        </tr>
                                                        <tr>
                                                            <td style="width: 30%;"><strong>备注:</strong></td>
                                                            <td style="word-break:break-all;">[[${ds.dsRemark}]]</td>
                                                        </tr>
                                                        </tbody>
                                                    </table>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </td>
                            </tr>
                            </tbody>
                            <tfoot>
                            <tr>
                                <td style="line-height: 34px">
                                    <input type="checkbox" name="" id="checkAllId" value="" onchange="checkAllId(this)">
                                </td>
                                <td colspan="12" style="text-align:left;padding-left:20px;">
                                    <button th:if="${session.user.authority!=3}" class="btn btn-danger btn-sm"
                                            th:onclick="dss_Delete()">
                                        <i class="fa fa-trash"></i> 批量删除
                                    </button>&nbsp;&nbsp;
                                    <a class="btn btn-primary btn-sm" style="padding: 5px 15px;"
                                       th:href="@{/ds/exportTemplate}"
                                       onclick="layer.msg('正在导出,请稍等...', { icon: 1, time: 1000 });">
                                        <i class="fa fa-download"></i> 导出当前页EXCEL模板
                                    </a>

                                    <a th:if="${session.user.authority==1}" class="btn btn-primary btn-sm"
                                       style="padding: 5px 15px;" th:href="@{/ds/export}"
                                       onclick="layer.msg('正在导出,请稍等...', { icon: 1, time: 1000 });">
                                        <i class="fa fa-download"></i> 导出到EXCEL
                                    </a>

                                    <a class="btn btn-primary btn-sm" data-toggle="modal" data-target="#mydialog1">
                                        <i class="fa fa-upload"></i> 导入EXCEL
                                    </a>
                                </td>
                            </tr>
                            </tfoot>
                        </table>

                        <!-- 分页 -->
                        <nav aria-label="Page navigation" style="text-align: right;">
                            <ul class="pagination">

                                <li>
                                    <a th:if="${pageBean.pageNum!=1 && searchURL==null}"
                                       th:href="@{/ds/dsShow(pageSize=${pageSize})}">首页</a>
                                </li>
                                <li>
                                    <a th:if="${pageBean.pageNum!=1 && searchURL!=null }"
                                       th:href="@{${searchURL}(pageSize=${pageSize})}">首页</a>
                                </li>

                                <li>
                                    <a th:if="${pageBean.pageNum==1 && searchURL==null}"
                                       href="javascript:void(0)">首页</a>
                                </li>
                                <li>
                                    <a th:if="${pageBean.pageNum==1 && searchURL!=null }"
                                       th:href="@{${searchURL}(pageSize=${pageSize})}">首页</a>
                                </li>

                                <li th:if="${pageBean.pageNum!=1 && searchURL==null}">
                                    <a th:href="@{/ds/dsShow(currentPage=${(pageBean.pageNum)-1},pageSize=${pageSize})}"
                                       aria-label="Previous">
                                        <span aria-hidden="true"><<</span>
                                    </a>
                                </li>
                                <li th:if="${pageBean.pageNum!=1 && searchURL!=null }">
                                    <a id="leftPage"
                                       th:href="@{${searchURL}(currentPage=${(pageBean.pageNum)-1},pageSize=${pageSize})}"
                                       aria-label="Previous">
                                        <span aria-hidden="true"><<</span>
                                    </a>
                                </li>

                                <li class="disabled" th:if="${pageBean.pageNum==1 }">
                                    <a href="javascript:void(0)" aria-label="Previous">
                                        <span aria-hidden="true"><<</span>
                                    </a>
                                </li>

                                <li th:classappend="${pageBean.pageNum==pageIndex}?'active':''"
                                    th:each="pageIndex:${pageValue}">
                                    <a href="javascript:void(0)"
                                       th:if="${pageBean.pageNum==pageIndex}"
                                       th:text="${pageIndex}"></a>
                                    <a th:if="${pageIndex==-1}" style="cursor: default;opacity: 0.6;">
                                        ...
                                    </a>
                                    <a th:if="${pageBean.pageNum!=pageIndex&&pageIndex!=-1 && searchURL==null}"
                                       th:href="@{/ds/dsShow(currentPage=${pageIndex},pageSize=${pageSize})}"
                                       th:text="${pageIndex}"></a>
                                    <a th:if="${pageBean.pageNum!=pageIndex&&pageIndex!=-1 && searchURL!=null}"
                                       th:href="@{${searchURL}(currentPage=${pageIndex},pageSize=${pageSize})}"
                                       th:text="${pageIndex}"></a>
                                </li>

                                <li class="disabled" th:if="${pageBean.pageNum==pageBean.pages }">
                                    <a href="javascript:void(0)" aria-label="Next">
                                        <span aria-hidden="true">>></span>
                                    </a>
                                </li>

                                <li th:if="${pageBean.pageNum!=pageBean.pages && searchURL==null}">
                                    <a th:href="@{/ds/dsShow(currentPage=${pageBean.pageNum+1},pageSize=${pageSize})}"
                                       aria-label="Next"> <span aria-hidden="true">>></span>
                                    </a>
                                </li>
                                <li th:if="${pageBean.pageNum!=pageBean.pages && searchURL!=null}">
                                    <a th:href="@{${searchURL}(currentPage=${pageBean.pageNum+1},pageSize=${pageSize})}"
                                       aria-label="Next"> <span aria-hidden="true">>></span>
                                    </a>
                                </li>

                                <li>
                                    <a th:if="${pageBean.pageNum!=pageBean.pages && searchURL==null}"
                                       th:href="@{/ds/dsShow(currentPage=${pageBean.pages},pageSize=${pageSize})}">末页</a>
                                </li>
                                <li>
                                    <a th:if="${pageBean.pageNum!=pageBean.pages && searchURL!=null}"
                                       th:href="@{${searchURL}(currentPage=${pageBean.pages},pageSize=${pageSize})}">末页</a>
                                </li>

                                <li>
                                    <a th:if="${pageBean.pageNum==pageBean.pages }"
                                       href="javascript:void(0)">末页</a>
                                </li>
                            </ul>
                        </nav>
                        <input id="currentPage" th:value="${pageBean.pageNum}" hidden>
                        <input id="currentPageSize" th:value="${pageBean.size}" hidden>
                        <input id="pageSizeOld" th:value="${pageSize}" hidden>
                        <input id="lastPage" th:value="${pageBean.pages}" hidden>
                    </div>
                    <!-- /.box-body -->
                </div>
                <!-- /.box -->
            </div>
            <!-- /.col -->
        </div>
        <!-- /.row -->
    </section>
    <!-- /.content -->
</div>
<!-- ./wrapper -->

<!-- DataTables -->
<script th:src="@{/asserts/bower_components/datatables.net/js/jquery.dataTables.min.js}"></script>
<script th:src="@{/asserts/bower_components/datatables.net-bs/js/dataTables.bootstrap.min.js}"></script>
<!-- SlimScroll -->
<script th:src="@{/asserts/bower_components/jquery-slimscroll/jquery.slimscroll.min.js}"></script>
<!-- FastClick -->
<script th:src="@{/asserts/bower_components/fastclick/lib/fastclick.js}"></script>
<!-- AdminLTE App -->
<script th:src="@{/asserts/dist/js/adminlte.min.js}"></script>
<!-- AdminLTE for demo purposes -->
<script th:src="@{/asserts/dist/js/demo.js}"></script>
<!-- page script -->
<script th:src="@{/asserts/Apolar_sh/lib/layer/2.4/layer.js}"></script>
<script>

    $(function () {
        $('#myTable').DataTable({
                "aaSorting": [
                    [1, "desc"]
                ],//默认第2列降序
                "bStateSave": true, //状态保存
                "aoColumnDefs": [{"bSortable": false, "aTargets": [0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12]}],
                "paging": false, //关闭页码
                "lengthChange": false,//关闭每页显示多少个选项
                "info": false,//关闭页码底端信息
                "searching": false,//关闭搜索栏
            }
        )
    })

    /*置顶*/
    $(function () {
        $(window).scroll(function () {
            if ($(window).scrollTop() > 150) {
                $('#top').css('display', 'block');    //<div id-'top'></div>假如有这么个div是那个向上图标的div。css默认none
            } else {
                $('#top').css('display', 'none');
            }
        });
    });

    /*修改*/
    function modify(dsId) {

        var pageSizeOld = $("#pageSizeOld").val();
        var currentPage = $("#currentPage").val();
        var dsDate = $("#dsDate").val();
        var dsSeller = $("#dsSeller").val();
        var dsPeople = $("#dsPeople").val();
        if ((location.href).indexOf("/ds/dsShow") !== -1) {
            location.href = "[[${#httpServletRequest.getContextPath()}]]/ds/dsModifyUI?dsId=" + dsId + "&currentPage=" + currentPage + "&pageSize=" + pageSizeOld;
        } else {
            location.href = "[[${#httpServletRequest.getContextPath()}]]/ds/dsModifyUI?dsId=" + dsId + "&currentPage=" + currentPage + "&pageSize=" + pageSizeOld + "&cdscDate=" + dsDate + "&cdscSeller=" + dsSeller + "&cdscPeople=" + dsPeople;
        }
    }

    /*每页显示*/
    function pageFun(obj) {
        if ((location.href).indexOf("/ds/dsShow") !== -1) {
            location.href = "[[${#httpServletRequest.getContextPath()}]]/ds/dsShow?pageSize=" + $(obj).val();
        } else {
            location.href = "[[${#httpServletRequest.getContextPath()}]]/ds/dsSearchShow?pageSize=" + $(obj).val() + "&cdscDate=" + $("#dsDate").val() + "&cdscSeller=" + $("#dsSeller").val() + "&cdscPeople=" + $("#dsPeople").val();
        }

    }

    /*非空判定*/
    $("form").submit(
        function () {
            var dsDate = $("#dsDate").val();
            var dsSeller = $("#dsSeller").val();
            var dsPeople = $("#dsPeople").val();
            if ((dsDate == null || dsDate === "") && (dsSeller == null || dsSeller === "") && (dsPeople == null || dsPeople === "")) {
                layer.msg('亲，查询内容不能为空哦!', {
                    icon: 0,
                    time: 1500
                });
                return false;
            }
            return true;
        }
    );

    var idArr = [];

    /*记住单个id*/
    function recordId(obj) {
        if (idArr.length === 0 || obj.checked === true) {
            idArr.push(obj.value);
        } else {
            for (var index in idArr) {
                if (idArr[index] === obj.value) {
                    delete idArr[index];
                }
            }
        }
    }

    /*记录所有id*/
    function checkAllId(obj) {

        var checknames = document.getElementsByName("dsIds");
        for (var i = 0; i < checknames.length; i++) {
            checknames[i].checked = obj.checked;
            if (obj.checked) {
                idArr.push(checknames[i].value);
            } else {
                idArr.length = 0;
            }
        }
    }

    /*删除-批量*/
    function dss_Delete() {
        var flag = true;
        for (var index in idArr) {
            if (idArr[index] != null) {
                flag = false;
            }
        }
        if (idArr.length === 0 || flag) {
            layer.msg('亲，请先选择要删除的项哦!', {
                icon: 0,
                time: 1500
            });
        } else {
            layer.confirm("确认要删除吗？",
                {
                    btn: ['确定', '取消']
                },
                function () {
                    var dsIdStr = idArr.toString();
                    var currentPageSize = $("#currentPageSize").val();
                    var currentPage = $("#currentPage").val();
                    var lastPage = $("#lastPage").val();
                    $.ajax({
                        type: 'POST',
                        url: './dssDelete?dsIdStr=' + dsIdStr + '&currentPageSize=' + currentPageSize + '&currentPage=' + currentPage + '&lastPage=' + lastPage,
                        success: function (data) {
                            if (data.id === 0) {
                                layer.msg(data.data, {
                                    icon: 1,
                                    time: 500
                                });
                                setTimeout(function () {
                                    if ((location.href).indexOf("/ds/dsShow") !== -1) {
                                        location.href = "[[${#httpServletRequest.getContextPath()}]]/ds/dsShow?pageSize=" + $("#pageSize").val() + "&currentPage=" + (currentPage - 1);
                                    } else {
                                        location.href = "[[${#httpServletRequest.getContextPath()}]]/ds/dsSearchShow?pageSize=" + $("#pageSize").val() + "&cdscDate=" + $("#dsDate").val() + "&cdscSeller=" + $("#dsSeller").val() + "&cdscPeople=" + $("#dsPeople").val() + "&currentPage=" + (currentPage - 1);
                                    }
                                }, 500);
                            } else if (data.id === 1) {
                                layer.msg(data.data, {
                                    icon: 1,
                                    time: 500
                                });
                                setTimeout(function () {
                                    location.replace(location.href);
                                }, 500);
                            } else {
                                layer.msg(data.data, {
                                    icon: 0,
                                    time: 2000
                                });
                            }
                        },
                        error: function (data) {
                            console.log(data.msg);
                        }
                    });
                },
                function () {
                    layer.msg("已取消！", {
                        icon: 0,
                        time: 500
                    });
                    return false;
                }
            );
        }
    }

    /*删除-单个*/
    function ds_delete(obj, dsId) {
        layer.confirm("确认要删除吗？",
            {
                btn: ['确定', '取消']
            },
            function () {
                var currentPageSize = $("#currentPageSize").val();
                var currentPage = $("#currentPage").val();
                var lastPage = $("#lastPage").val();
                $.ajax({
                    type: 'POST',
                    url: './dsDelete?dsId=' + dsId + '&currentPageSize=' + currentPageSize + '&currentPage=' + currentPage + '&lastPage=' + lastPage,
                    success: function (data) {
                        if (data.id === 0) {
                            layer.msg(data.data, {
                                icon: 1,
                                time: 500
                            });
                            setTimeout(function () {
                                if ((location.href).indexOf("/ds/dsShow") !== -1) {
                                    location.href = "[[${#httpServletRequest.getContextPath()}]]/ds/dsShow?pageSize=" + $("#pageSize").val() + "&currentPage=" + (currentPage - 1);
                                } else {
                                    location.href = "[[${#httpServletRequest.getContextPath()}]]/ds/dsSearchShow?pageSize=" + $("#pageSize").val() + "&cdscDate=" + $("#dsDate").val() + "&cdscSeller=" + $("#dsSeller").val() + "&cdscPeople=" + $("#dsPeople").val() + "&currentPage=" + (currentPage - 1);
                                }
                            }, 500);
                        } else if (data.id === 1) {
                            layer.msg(data.data, {
                                icon: 1,
                                time: 500
                            });
                            setTimeout(function () {
                                location.replace(location.href);
                            }, 500);
                        } else {
                            layer.msg(data.data, {
                                icon: 0,
                                time: 2000
                            });
                        }
                    },
                    error: function (data) {
                        console.log(data.msg);
                    }
                });
            },
            function () {
                layer.msg("已取消！", {
                    icon: 0,
                    time: 500
                });
                return false;
            }
        );
    }

    /*联想输入*/
    $(function () {
        $("#dsSeller").bigAutocomplete({
            url: '[[${#httpServletRequest.getContextPath()}]]/find/allUsersNbossJson',
        });
    })

    /*文件上传*/
    var $uploadExcel = $("#input-b2");

    function uploadExcel() {
        if ($uploadExcel.val() === "") {
            layer.msg('亲，请选择文件哦!', {
                icon: 0,
                time: 1500
            });
        } else {
            var file = document.getElementById("input-b2").files[0];
            var formData = new FormData();
            formData.append("file", file);
            layer.msg("正在导入,请稍等...", {
                icon: 1,
                time: 1000
            });
            $.ajax({
                type: 'POST',
                url: './dsUploadExcel',
                data: formData,
                dataType: 'json',
                processData: false,
                contentType: false,
                mimeType: "multipart/form-data",
                success: function (data) {
                    if (data.id === 0) {
                        layer.msg(data.data, {
                            icon: 1,
                            time: 500
                        });
                        $('#mydialog1').modal('hide');
                        setTimeout(function () {
                            location.replace(location.href);
                        }, 500);
                    } else {
                        layer.msg(data.data, {
                            icon: 0,
                            time: 2000
                        });
                        $('#mydialog1').modal('hide');
                    }
                },
                error: function (data) {
                    console.log(data.msg);
                }
            })
        }
    }
</script>
</body>
</html>